package com.zzz.views;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

import java.util.StringJoiner;

/**
 * 所有视图的入口
 */
@Controller
public class ViewAction {
    @GetMapping("/")
    public String index() {
        return "index";
    }

    @GetMapping("/views/{path}")
    public ModelAndView views(@PathVariable("path") String path) {
        return new ModelAndView(new StringJoiner("/").add("views").add(path).toString());
    }

    @GetMapping("/views/{path1}/{path2}")
    public ModelAndView views2(@PathVariable("path1") String path1,
                               @PathVariable("path2") String path2) {
        return new ModelAndView(new StringJoiner("/").add("views").add(path1).add(path2).toString());
    }

    @GetMapping("/views/{path1}/{path2}/{path3}")
    public ModelAndView views3(@PathVariable("path1") String path1,
                               @PathVariable("path2") String path2,
                               @PathVariable("path3") String path3) {
        return new ModelAndView(new StringJoiner("/").add("views").add(path1).add(path2).add(path3).toString());
    }
}
